﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="NewAlertPage.ascx.cs"
    Inherits="Workflow.Alerts.Sublayouts.NewAlertPage" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxtoolkit" %>
<br />
<div class="contentHeader">
    <h1 class="h1PageTitle floatLeft">
        <asp:Label ID="ListName" runat="server" Text="Nieuwe melding"></asp:Label>
    </h1>
</div>
<div class="clear">
</div>
<asp:Panel ID="Panel1" runat="server" DefaultButton="btnSave" CssClass="panel">
    <div class="outerContentBox">
        <dl class="tag_newAlert newAlert">
            <dt class="first"><span class="headerNumber">1</span> <span class="header">Gemeente</span>
                <span class="selected tag_selected"></span></dt>
            <dd class="step1">
                <div id="gemeente" runat="server">
                    <div id="municipalityarea" runat="server">
                        <asp:Repeater runat="server" ID="rptMunicipality" OnItemDataBound="rptMunicipality_ItemDataBound">
                            <HeaderTemplate>
                                <ul class="radioButtonList municipalities tag_municipalities">
                            </HeaderTemplate>
                            <ItemTemplate>
                                <li>
                                    <asp:RadioButton ID="rbMunicipality" runat="server" GroupName="Municipality" Text='<%# Eval("name") %>'
                                        CssClass="radioButton" />
                                    <input type="hidden" class="tag_lat" value='<%# Eval("lat") %>' />
                                    <input type="hidden" class="tag_lng" value='<%# Eval("lng") %>' />
                                    <input type="hidden" class="tag_zoom" value='<%# Eval("zoomlevel") %>' />
                                    <input type="hidden" runat="server" id="municipalityid" value='<%# Eval("id") %>' />
                                </li>
                            </ItemTemplate>
                            <FooterTemplate>
                                </ul>
                            </FooterTemplate>
                        </asp:Repeater>
                        <input type="hidden" runat="server" id="selectedMunicipality" />
                    </div>
                </div>
                <div class="clear">
                </div>
            </dd>
            <dt class="tag_map"><span class="headerNumber">2</span> <span class="header">Locatie</span>
                <span class="selected tag_selected floatRight"></span></dt>
            <dd class="step2">
                <div id="locatie" runat="server">
                    <div id="maparea" runat="server" class="mapContainer floatLeft">
                        <div id="Map" class="map">
                        </div>
                        <input id="ClearMap" type="button" value="Verwijder" class="clearMap styledButton styledButton75" />
                    </div>
                    <div id="location" runat="server" class="locationFormContainer floatLeft">
                        <div id="MarkerType" runat="server" class="tag_markerType radioMarkerType">
                            <h3 class="h3PageTitle">
                                1.Hoe wilt u de lokatie weergeven?</h3>
                            <ul class="radioButtonList">
                                <li>
                                    <asp:RadioButton ID="rdMarker" runat="server" GroupName="markerType" Checked="true"
                                        Text="Marker plaatsen" EnableViewState="true" CssClass="radioButton" /></li>
                                <li>
                                    <asp:RadioButton ID="rdArea" runat="server" GroupName="markerType" Text="Gebied tekenen"
                                        EnableViewState="true" CssClass="radioButton" /></li>
                            </ul>
                        </div>
                        <div id="marker" runat="server" class="tag_markerInput">
                            <h3 class="h3PageTitle">
                                Marker plaatsen</h3>
                            <span>Geef een lokatie op(b.v. Damrak 5, Amsterdam - of 5000 AA):</span>
                            <div class="markerInputContainer">
                                <asp:UpdatePanel ID="upLocation" runat="server" UpdateMode="Always">
                                    <ContentTemplate>
                                        <asp:TextBox ID="rcbLocation" runat="server" class="styledInput styledInput450ok floatLeft rcbInput"></asp:TextBox>
                                    </ContentTemplate>
                                </asp:UpdatePanel>
                                <asp:Button ID="btnShowOnMap" runat="server" Text="OK" class="styledButton inputSideButton floatLeft" />
                            </div>
                            <span>Óf klik in de kaart om een lokatie op te vragen:</span>
                            <input id="Button2" type="button" value="Bevestig Marker" class="tag_gotoStep3 styledButton styledButton150 buttonBevestigMarker" />
                            <span class="gotoStep3 tag_gotoStep3 errorMessage"></span>
                        </div>
                        <div id="area" runat="server" class="tag_areaInput">
                            <h3 class="h3PageTitle">
                                2. Teken een gebied</h3>
                            <span class="rowBoxLabel">Klik in de kaart om een polygoon met minimaal 3 punten te
                                tekenen.<br />
                                De punten zijn achteraf met de muis te verslepen.
                                <br />
                                <br />
                                Geef het gebied daarna een beschrijvende naam.
                                <br />
                            </span>
                            <div class="markerInputContainer">
                                <asp:Label ID="labelLocationDescription" runat="server" Text="Naam gebied:" AssociatedControlID="txtLocationDescription"></asp:Label>
                                <asp:TextBox ID="txtLocationDescription" runat="server" CssClass="tag_areaDesciption styledInput styledInput450ok floatLeft"></asp:TextBox>
                                <input id="Button1" type="button" value="OK" class="tag_gotoStep3 styledButton inputSideButton floatLeft" />
                            </div>
                            <span class="gotoStep3 tag_gotoStep3Area errorMessage"></span>
                        </div>
                        <div>
                            <asp:CustomValidator ID="cvLocation" runat="server" ErrorMessage="Location is not valid"
                                OnServerValidate="cvLocation_ServerValidate"></asp:CustomValidator>
                            <asp:CustomValidator ID="cvArea" runat="server" ErrorMessage="Please provide area on the map"
                                OnServerValidate="cvArea_ServerValidate" ClientValidationFunction="cvAreaValidate"
                                ValidationGroup="cvarea" />
                        </div>
                    </div>
                </div>
                <input id="coordinatesMarker" type="hidden" class="tag_markerLatLng" runat="server" />
                <input id="coordinatesArea" type="hidden" class="tag_areaPoints" runat="server" />
                <div class="clear">
                </div>
            </dd>
            <dt class="js_step3"><span class="headerNumber">3</span> <span class="header">Gegevens</span>
            </dt>
            <dd class="step3">
                <div id="gegevens" runat="server" class="gegevensForm">
                    <div class="gegevensFormLeft floatLeft">
                        <div id="alerttype" runat="server" class="boxRow">
                            <asp:Label runat="server" ID="label1" AssociatedControlID="ddlAlertType" Text="Soort aanvraag"
                                CssClass="settingsLabel"></asp:Label>
                            <asp:DropDownList runat="server" ID="ddlAlertType" CssClass="hiddenDropdown js_hiddenDropdown styledDropdown220">
                            </asp:DropDownList>
                            <div class="clear">
                            </div>
                        </div>
                        <div id="activity" runat="server" class="boxRow">
                            <asp:Label runat="server" ID="label2" AssociatedControlID="ddlActivity" Text="Activiteit"
                                CssClass="settingsLabel"></asp:Label>
                            <asp:DropDownList runat="server" ID="ddlActivity" CssClass="hiddenDropdown js_hiddenDropdown styledDropdown220">
                            </asp:DropDownList>
                            <div class="clear">
                            </div>
                        </div>
                        <div runat="server" id="estimatearea" class="boxRow">
                            <asp:Label runat="server" ID="label3" AssociatedControlID="txtArea" Text="Geschatte oppervlakte"
                                CssClass="settingsLabel"></asp:Label>
                            <telerik:RadNumericTextBox ID="txtArea" EnableEmbeddedBaseStylesheet="false" EnableEmbeddedSkins="false"
                                Skin="workflowArea" runat="server" CssClass="actualArea styledInput styledInputM2"
                                ShowSpinButtons="false" MinValue="1" MaxValue="15" NumberFormat-DecimalDigits="0" />
                            <asp:RequiredFieldValidator ID="rfvArea" ControlToValidate="txtArea" runat="server"
                                ErrorMessage="Verplicht veld" Display="Dynamic" />
                            <div class="clear">
                            </div>
                        </div>
                        <div runat="server" id="estimatestartdate" class="boxRow">
                            <asp:Label runat="server" ID="label4" AssociatedControlID="rdpEstimateStartDate"
                                Text="Start" CssClass="settingsLabel"></asp:Label>
                            <telerik:RadDatePicker ID="rdpEstimateStartDate" runat="server" EnableEmbeddedBaseStylesheet="False"
                                EnableEmbeddedSkins="False" Skin="workflow">
                                <ClientEvents OnDateSelected="setMinDate" />
                            </telerik:RadDatePicker>
                            <br />
                            <asp:RequiredFieldValidator ID="rfvStartDate" ControlToValidate="rdpEstimateStartDate"
                                runat="server" ErrorMessage="Verplicht veld" Display="Dynamic" />
                        </div>
                        <div runat="server" id="estimateenddate" class="boxRow">
                            <asp:Label runat="server" ID="label5" AssociatedControlID="rdpEstimateEndDate" Text="Gereed"
                                CssClass="settingsLabel"></asp:Label>
                            <telerik:RadDatePicker ID="rdpEstimateEndDate" runat="server" EnableEmbeddedBaseStylesheet="False"
                                EnableEmbeddedSkins="False" Skin="workflow">
                            </telerik:RadDatePicker>
                            <br />
                            <asp:RequiredFieldValidator ID="rfvEndDate" ControlToValidate="rdpEstimateEndDate"
                                runat="server" ErrorMessage="Verplicht veld" Display="Dynamic" />
                            <asp:CompareValidator ID="CompareValidator1" runat="server" ErrorMessage="Einddatum moet na begindatum zijn."
                                Operator="GreaterThanEqual" ControlToValidate="rdpEstimateEndDate" ControlToCompare="rdpEstimateStartDate"
                                Display="Dynamic" Type="Date" />
                            <div class="clear">
                            </div>
                        </div>
                        <div id="contactperson" runat="server" class="boxRow">
                            <asp:Label runat="server" ID="label6" AssociatedControlID="ddlPerson" Text="Contactpersoon"
                                CssClass="settingsLabel"></asp:Label>
                            <asp:DropDownList runat="server" ID="ddlPerson" CssClass="hiddenDropdown js_hiddenDropdown styledDropdown220">
                            </asp:DropDownList>
                            <div class="clear">
                            </div>
                        </div>
                    </div>
                    <div class="gegevensFormRight floatLeft">
                        <div id="trafficproblems" runat="server" class="boxRow">
                            <span class="rowBoxLabel floatLeft">Wordt verkeershinder verwacht</span>
                            <asp:RadioButtonList ID="rblTrafficProblems" runat="server" RepeatDirection="Horizontal"
                                CssClass="radioButtonList">
                                <asp:ListItem Text="ja" Value="True" class="radioButton"></asp:ListItem>
                                <asp:ListItem Text="nee" Value="False" class="radioButton"></asp:ListItem>
                            </asp:RadioButtonList>
                        </div>
                        <div class="clear">
                        </div>
                        <div id="trafficcomments" runat="server" class="boxRow">
                            <span class="rowBoxLabel">Omschrijving verwachte verkeershinder</span>
                            <br />
                            <asp:TextBox ID="txtTrafficComments" runat="server" TextMode="MultiLine" Rows="7" Columns="60"></asp:TextBox>
                        </div>
                    </div>
                </div>
                <div class="clear">
                </div>
            </dd>
        </dl>
    </div>
    <div class="footerButtonContainer">
        <telerik:RadInputManager ID="rimNewAlert" runat="server" EnableEmbeddedBaseStylesheet="false"
            EnableEmbeddedSkins="false" Skin="workflow">
            <telerik:NumericTextBoxSetting BehaviorID="NumberBehavior" EmptyMessage="type.."
                Type="Number" DecimalDigits="0" MinValue="0" MaxValue="100" />
        </telerik:RadInputManager>
        <asp:Button ID="btnSave" runat="server" Text="Opslaan" CausesValidation="true" OnClick="btnSave_Click"
            CssClass="tag_newAlertSave floatLeft styledButton styledButton75" />
        <asp:Button ID="btnSaveSend" runat="server" Text="Opslaan en verzenden" OnClick="btnSaveSend_Click"
            CssClass="tag_newAlertSave floatLeft styledButton styledButton200" />
        <asp:Button ID="btnCancel" runat="server" Text="Annuleren" OnClick="btnCancel_Click"
            CausesValidation="False" CssClass="styledButton floatLeft styledButton150" />
        <asp:Button ID="btnDelete" runat="server" Text="Verwijderen" CausesValidation="False"
            Visible="false" OnClick="btnDelete_Click" CssClass="styledButton styledButton150 floatLeft js_deleteAlert" />
    </div>
    <div class="clear">
    </div>
    <div class="overlay">
    </div>
</asp:Panel>

<script type="text/javascript">

    jQuery(document).ready(function() {
        workflow.form.radioButtonCtrl.SetupLabel()
        
        workflow.form.select.Init(".js_hiddenDropdown:not(.init)");
        
        jQuery("a.rcCalPopup").not(".rcDisabled").click(function(){
            var docWidth = jQuery(document).width();
            var calWidth = jQuery(".RadCalendar_workflow").width();
            var leftOffset = (docWidth - calWidth)/2;
            jQuery(".RadCalendarPopup").css({
                "left":leftOffset,
                "top":"190px"
            });
        });
        jQuery(".rcMainTable tbody td").click(function(){
            jQuery(".RadCalendarPopup").fadeOut("fast");
        });
        
    });

    var newAlertMap;
    workflow.newAlert.Set('dl.tag_newAlert')

    function SetButton(id, current, nameregex) {
        re = new RegExp(nameregex);
        for (i = 0; i < document.forms[0].elements.length; i++) {
            elm = document.forms[0].elements[i];
            if (elm.type == 'radio') {
                if (re.test(elm.name)) {
                    elm.checked = false;
                }
            }
        }
        current.checked = true;
        document.getElementById("<%= selectedMunicipality.ClientID %>").value = id;
    }

    function cvAreaValidate(source, arguments) {

        if (jQuery('input.tag_markerLatLng').val() != "") {
            arguments.IsValid = true;
        } else {
            arguments.IsValid = false;
        }
    }


    function setMinDate() {
        var rdpEstimateEndDate = $find("<%= rdpEstimateEndDate.ClientID %>");
        var rdpEstimateStartDate = $find("<%= rdpEstimateStartDate.ClientID %>");
       
        var date = rdpEstimateStartDate.get_selectedDate();
        rdpEstimateEndDate.set_minDate(date);
    }

//   Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequest);

//   function EndRequest(sender, args) {

//       workflow.form.select.Init(".js_hiddenDropdown:not(.init)");
////       if (postBackElement.id == '<%Response.Write(rptMunicipality.ClientID.ToString());%>') {           
////       }
//   }
    
</script>

